﻿
Imports System.Text
Imports std
Imports elpmis
Imports elpmis.internalFunctions

Namespace lpmsrunr_s_functions
    Public Class writeconsole
        Inherits elpmis.internalFunctions.writeConsole

        Protected Overrides Sub write(ByVal o As String)
            Dim bs() As Byte
            bs = encoding.utf8().GetBytes(o)
            stdout.Write(bs, 0, bs.Length())
        End Sub
    End Class

    Public Class writeconsoleline
        Inherits writeconsole

        Protected Overrides Sub write(ByVal o As String)
            MyBase.write(o + newline.incode())
        End Sub
    End Class

    Public Class readconsole
        Inherits elpmis.internalFunctions.readConsole

        Protected Overrides Function readline() As String
            Static until As Byte = encoding.utf8().GetBytes(character.newline)(0)
            Dim v As vector(Of Byte) = Nothing
            v = New vector(Of Byte)()
            Dim bs(0) As Byte
            While bs(0) <> until
                readstdi(bs, 1)
                v.push_back(bs(0))
            End While

            Return encoding.utf8().GetString(v.rawdata(), 0, v.size())
        End Function
    End Class
End Namespace
